﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace Agresso.Interface.Layer.Domain
{
    public class apodetail
    {
        public long order_id = 0;
        public string ext_ord_ref = "";
        public int line_no = 0;
        public string sup_article = "";
        public string client = "";
        public string status = "";
        public string art_descr = "";

        public long i_apodetail_id = 0;
        public string pickup_flag = "";
        public DateTime pickup_date = new DateTime(1900, 1, 1);
        public DateTime insert_date = new DateTime(1900, 1, 1);
        public string remarks = "";

        public apodetail() { }
        public apodetail(SqlDataReader rd)
        {
            order_id = rd["order_id"] is DBNull ? 0 : Convert.ToInt64(rd["order_id"]);
            ext_ord_ref = rd["ext_ord_ref"] is DBNull ? "" : rd["ext_ord_ref"].ToString();
            line_no = rd["line_no"] is DBNull ? 0 : Convert.ToInt32(rd["line_no"]);
            sup_article = rd["sup_article"] is DBNull ? "" : rd["sup_article"].ToString();
            client = rd["client"] is DBNull ? "" : rd["client"].ToString();
            status = rd["status"] is DBNull ? "" : rd["status"].ToString();
            art_descr = rd["art_descr"] is DBNull ? "" : rd["art_descr"].ToString();
        }
        public static apodetail apodetailFromInterface(SqlDataReader rd)
        {
            apodetail result = new apodetail(rd);
            result.i_apodetail_id = rd["i_apodetail_id"] is DBNull ? 0 : Convert.ToInt64(rd["i_apodetail_id"]);
            result.pickup_flag = rd["pickup_flag"] is DBNull ? "" : rd["pickup_flag"].ToString();
            result.pickup_date = rd["pickup_date"] is DBNull ? result.pickup_date : Convert.ToDateTime(rd["pickup_date"]);
            result.insert_date = rd["insert_date"] is DBNull ? result.insert_date : Convert.ToDateTime(rd["insert_date"]);
            result.remarks = rd["remarks"] is DBNull ? "" : rd["remarks"].ToString();
            result.art_descr = rd["art_descr"] is DBNull ? "" : rd["art_descr"].ToString();
            return result;
        }
        public static apodetail apodetailFromInterfacePending(SqlDataReader rd)
        {
            apodetail result = new apodetail();
            result.order_id = rd["order_id"] is DBNull ? 0 : Convert.ToInt64(rd["order_id"]);
            result.ext_ord_ref = rd["ext_ord_ref"] is DBNull ? "" : rd["ext_ord_ref"].ToString();
            result.sup_article = rd["sup_article"] is DBNull ? "" : rd["sup_article"].ToString();
            result.status = rd["status"] is DBNull ? "" : rd["status"].ToString();
            result.pickup_date = rd["pickup_date"] is DBNull ? result.pickup_date : Convert.ToDateTime(rd["pickup_date"]);
            result.remarks = rd["remarks"] is DBNull ? "" : rd["remarks"].ToString();
            result.art_descr = rd["art_descr"] is DBNull ? "" : rd["art_descr"].ToString();
            result.client = rd["client"] is DBNull ? "" : rd["client"].ToString();
            return result;
        }
    }
}
